﻿Class MainWindow

    Private Sub Window_Loaded(sender As Object, e As System.Windows.RoutedEventArgs)

        Dim Cultures = System.Globalization.CultureInfo.GetCultures(System.Globalization.CultureTypes.AllCultures)

        Dim InvariantItem = CultureSynopsysControl.CreateTreeViewItem(System.Globalization.CultureInfo.InvariantCulture)

        Me.CultureTreeView.Items.Add(InvariantItem)

        AddChildCulture(Cultures, InvariantItem, System.Globalization.CultureInfo.InvariantCulture)
    End Sub

    Private Sub AddChildCulture(Cultures As System.Globalization.CultureInfo(), ParentItem As System.Windows.Controls.TreeViewItem, ParentCulture As System.Globalization.CultureInfo)

        For Each C In Cultures

            If C.Parent.Equals(ParentCulture) AndAlso Not C.Equals(System.Globalization.CultureInfo.InvariantCulture) Then

                Dim TItem = CultureSynopsysControl.CreateTreeViewItem(C)

                ParentItem.Items.Add(TItem)

                AddChildCulture(Cultures, TItem, C)
            End If
        Next
    End Sub

    Private Sub CultureTreeView_SelectedItemChanged(sender As Object, e As System.Windows.RoutedPropertyChangedEventArgs(Of Object)) Handles CultureTreeView.SelectedItemChanged

        Dim SelectedItem As System.Windows.Controls.TreeViewItem = Me.CultureTreeView.SelectedItem
        Dim SelectedCulture As System.Globalization.CultureInfo = SelectedItem.Tag

        Dim TDetails = CultureDetailedControl.CreateTreeViewItem(SelectedCulture)

        Me.DetailsContentControl.Content = TDetails
    End Sub
End Class
